package com.zheng1.envii.room.Repository

import android.location.Address
import androidx.annotation.WorkerThread
import com.zheng1.envii.room.dao.EnvIIBleDeviceDataDao
import com.zheng1.envii.room.entity.EnvIIBleDeviceDataEntity
import kotlinx.coroutines.flow.Flow


class EnvIIBleDeviceRepository( private val envIIBleDeviceDataDao : EnvIIBleDeviceDataDao) {

    fun getDeviceDataByAddress(address: String) : Flow<List<EnvIIBleDeviceDataEntity>> =
        envIIBleDeviceDataDao.getDeviceDataByAddress(address)

    @Suppress("RedundantSuspendModifier")
    @WorkerThread
    suspend fun insert(envIIBleDeviceDataEntity: EnvIIBleDeviceDataEntity) {
        envIIBleDeviceDataDao.insertDeviceData(envIIBleDeviceDataEntity)
    }

    @Suppress("RedundantSuspendModifier")
    @WorkerThread
    suspend fun delete(address: String) {
        envIIBleDeviceDataDao.deleteDeviceDataByAddress(address)
    }

}